
/**
 * @description: <a href="https://leetcode.cn/problems/jump-game/description/">55. 跳跃游戏</a>
 * @author: zhaoyinglin
 * @date: 2024/3/6
 */
public class JumpGame {

    public static void main(String[] args) {
        int[] nums = new int[] { 0, 2, 3 };

        System.out.println(canJump(nums));
    }

    public static boolean canJump(int[] nums) {

        int n = nums.length;

        int maxJumpIndex = 0;

        for (int i = 0; i < n - 1; i++) {
            maxJumpIndex = Math.max(maxJumpIndex, i + nums[i]);
        }

        System.out.println("maxJumpIndex " + maxJumpIndex);

        return maxJumpIndex >= (n - 1);
    }

}
